.gallery {
  box-sizing: border-box;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px;
  width: 100%;
  overflow-y: auto;
  background-color: #000;
}

.gallery-item {
  position: relative;
  z-index: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  width: 120px;
  height: 150px;
  background-color: transparent;
  background-position: center center;
  background-size: contain;
  background-repeat: no-repeat;
  transition: transform .16s ease-in-out;

  &:first-child {
    margin-left: 0;
  }

  &:last-child {
    margin-right: 0;
  }

  &:before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(135deg,
      transparent 10%,
      rgba(255,255,255,.05) 10%,
      rgba(255,255,255,.05) 20%,
      transparent 20%,
      transparent 30%,
      rgba(255,255,255,.05) 30%,
      rgba(255,255,255,.05) 40%,
      transparent 40%,
      transparent 50%,
      rgba(255,255,255,.05) 50%,
      rgba(255,255,255,.05) 60%,
      transparent 60%,
      transparent 70%,
      rgba(255,255,255,.05) 70%,
      rgba(255,255,255,.05) 80%,
      transparent 80%,
      transparent 90%,
      rgba(255,255,255,.05) 90%
    );
    background-color: rgba(255,255,255,.05);
    box-shadow: inset 0 0 0 4px rgba(255,255,255,.05);
  }

  &:after {
    content: "";
    position: relative;
    z-index: 4;
    display: block;
    width: 100%;
    height: 100%;
    background-image: inherit;
    background-color: inherit;
    background-position: inherit;
    background-size: inherit;
    background-repeat: inherit;
    transition: transform .16s ease-in-out;
    pointer-events: none;
  }

  &:hover {
    transform: scale(1.1);
  }

  &.active:after {
    border-radius: 2px;
    transform: scale(1.02);
    animation: transition 1.6s ease-in-out infinite;
  }
}

@media screen and (orientation: portrait) {
  .gallery-item {
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    width: percentage(1/3);
    height: percentage(1/4);

    &:before {
      box-shadow: inset 0 0 0 8px rgba(255,255,255,.05);
    }
  }
}

@keyframes transition {
  0% {
    background-color: rgba(255,255,255,.1);
    box-shadow: 0 0 0 3px rgba(255,255,255,.2);
  }

  50% {
    background-color: rgba(255,255,255,.2);
    box-shadow: 0 0 0 3px rgba(255,255,255,.5);
  }

  100% {
    background-color: rgba(255,255,255,.1);
    box-shadow: 0 0 0 3px rgba(255,255,255,.2);
  }
}
